/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VistaListadoIngrediente.java
 *
 * Created on 08/04/2011, 09:20:54 AM
 */

package vistas;

import controladores.ControladorListadoIngrediente;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.util.Vector;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import modelos.ModeloIngrediente;

/**
 *
 * @author usuario
 */
public class VistaListadoIngrediente extends javax.swing.JFrame {
    private ControladorListadoIngrediente control;
    private DefaultTableModel modeloTabla;
    private Vector<String> fila;

    /** Creates new form VistaListadoIngrediente */
    public VistaListadoIngrediente() {
        initComponents();
        modeloTabla= new DefaultTableModel();
        tblListado.setModel(modeloTabla);

        fila= new Vector<String>();

        fila.add("Ingrediente");
        fila.add("Cantidad Disponible en Almacen");
        modeloTabla.setColumnIdentifiers(fila);
        
        control = new  ControladorListadoIngrediente(this);
        addAction();
    }
    
  
    
    public void windowClosing(WindowEvent e){
		setVisible(false);
	}

    public void addListener(ActionListener escuchador){
        btnSalir.addActionListener(escuchador);
        btnConsultar.addActionListener(escuchador);
    }

    public void addAction(){
            btnConsultar.setActionCommand("Consultar");
            btnSalir.setActionCommand("Salir");
    }

    public void agregar(ModeloIngrediente m){
        fila= new Vector<String>();
        fila.add(m.getDescripcion());
        fila.add(""+m.getStock());

                modeloTabla.addRow(fila);
            
        }

    public DefaultTableModel getModeloTabla() {
        return modeloTabla;
    }




    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        tblListado = new javax.swing.JTable();
        btnSalir = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        btnConsultar = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        tblListado.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
        tblListado.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tblListado);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(20, 70, 452, 370);

        btnSalir.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
        btnSalir.setText("Salir");
        getContentPane().add(btnSalir);
        btnSalir.setBounds(260, 450, 120, 30);

        jLabel4.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(247, 237, 237));
        jLabel4.setText("Disponibilidad de Ingrdientes");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(140, 20, 290, 22);

        btnConsultar.setFont(new java.awt.Font("Arial", 1, 15)); // NOI18N
        btnConsultar.setText("Consultar");
        getContentPane().add(btnConsultar);
        btnConsultar.setBounds(100, 450, 120, 30);

        jLabel1.setBackground(new java.awt.Color(15, 50, 220));
        jLabel1.setOpaque(true);
        getContentPane().add(jLabel1);
        jLabel1.setBounds(0, 0, 500, 500);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-500)/2, (screenSize.height-522)/2, 500, 522);
    }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VistaListadoIngrediente().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable tblListado;
    // End of variables declaration//GEN-END:variables

}
